package com.wsd.constant;

/**
 * @author Wan Yucan
 * @date 2020/7/30-11:25
 */
public enum RepaymentTypeEnum {
    /**
     * 用于传入loan类的贷款方式
     * 示例：
     * loan.setRepaymentType(RepaymentTypeEnum.INTEREST_BEFORE_PRINCIPAL.getType());
     */
    ERROR(0,'0'),
    //等额本金
    EQUAL_PRINCIPAL(1,'1'),
    //等额本息
    EQUAL_PRINCIPAL_AND_INTEREST(2,'2'),
    //先息后本
    INTEREST_BEFORE_PRINCIPAL(3,'3');

    private  int value;
    private char type;
    RepaymentTypeEnum(int value,char type) {
        this.type = type;
        this.value=value;
    }

    public int getValue() {
        return value;
    }

    public char getType() {
        return type;
    }

    public static RepaymentTypeEnum getType(char type){
        for (RepaymentTypeEnum enums : RepaymentTypeEnum.values()) {
            if (enums.getType() == type) {
                return enums;
            }
        }
        return null;
    }

}
